﻿
var genNewSequenceNo = function (obj, sequenceName) {
    var sequenceNo = obj.val();

    if (sequenceNo == "" || sequenceNo == null) {
        $.ajax({
            async: false, //异步请求
            cache: false, //不从浏览器缓存中加载
            type: "GET",
            dataType: "json",
            url: "/DCBH/DCBHCommonOperator.aspx",
            data: { Action: "gennewsequenceno", SequenceName: sequenceName },
            success: function (data) {
                if (data != null && data.Staute == "Success" && data.Msg != "") {
                    obj.val(data.Msg);
                    return;
                }
            },
            error: function (e) {
                alert("请联系开发人员，核查系统！");
                return;
            }
        });
    }
}


var fnGetMyDate = function (date) {
    y = date.getFullYear();
    m = date.getMonth() + 1;
    d = date.getDate();
    m = m < 10 ? "0" + m : m;
    d = d < 10 ? "0" + d : d;
    return myDate = y + "-" + m + "-" + d
}

function clearNoNum(event, obj) {
    //响应鼠标事件，允许左右方向键移动 
    event = window.event || event;
    if (event.keyCode == 37 | event.keyCode == 39) {
        return;
    }
    //先把非数字的都替换掉，除了数字和. 
    obj.val(obj.val().replace(/[^\d.]/g, ""));
    //必须保证第一个为数字而不是. 
    obj.val(obj.val().replace(/^\./g, ""));
    //保证只有出现一个.而没有多个. 
    obj.val(obj.val().replace(/\.{2,}/g, "."));
    //保证.只出现一次，而不能出现两次以上 
    obj.val(obj.val().replace(".", "$#$").replace(/\./g, "").replace("$#$", "."));

}

function checkNum(obj) {
    //为了去除最后一个. 
    obj.val(obj.val().replace(/\.$/g, ""));
}

/*
var qtyObj = trs.find("input[name='Qty']");
qtyObj.bind("blur", function () { var o = $(this); checkNum(o); });
qtyObj.bind("keyup", function () { var o = $(this); clearNoNum(event, o); });

var scrapObj = trs.find("input[name='ScrapQty']");
scrapObj.bind("blur", function () { var o = $(this); checkNum(o); });
scrapObj.bind("keyup", function () { var o = $(this); clearNoNum(event, o); });
*/